package com.imooc.service.combine.impl;

import com.imooc.entity.bo.HeadLine;
import com.imooc.entity.bo.ShopCategory;
import com.imooc.entity.dto.MainPageInfoDTO;
import com.imooc.entity.dto.Result;
import com.imooc.service.combine.HeadLineShopCategoryCombineService;
import com.imooc.service.solo.HeadLineService;
import com.imooc.service.solo.ShopCategoryService;

import java.util.List;

/**
 * @author 折戟沉沙铁未销
 * @version V1.0
 * @date 2020/7/7-2020
 * @Description: 这里用一句话描述这个类的作用
 */
public class HeadLineShopCategoryCombineServiceImpl implements HeadLineShopCategoryCombineService {

    private HeadLineService headLineService;
    private ShopCategoryService shopCategoryService;

    @Override
    public Result<MainPageInfoDTO> getMainPageInfo() {
        //1:获取头条列表
        HeadLine headLineCondition=new HeadLine();
        headLineCondition.setEnableStatus(1);
        Result<List<HeadLine>> headLineResult = headLineService.queryHeadLine(headLineCondition, 1, 100);
        //2：获取店铺列表
        ShopCategory shopCategoryCondition=new ShopCategory();
        Result<List<ShopCategory>> shopCategoryResult = shopCategoryService.queryShopCategory(shopCategoryCondition, 1, 100);
        //3：合并两者
        MainPageInfoDTO mainPageInfoDTO=new MainPageInfoDTO();
        mainPageInfoDTO.setHeadLineList(headLineResult.getData());
        mainPageInfoDTO.setShopCategoryList(shopCategoryResult.getData());
        //4：封装返回结果.并返回
        Result<MainPageInfoDTO> mainPageInfoDTOResult=new Result<>();
        mainPageInfoDTOResult.setCode(200);
        mainPageInfoDTOResult.setData(mainPageInfoDTO);
        return mainPageInfoDTOResult;
    }
}
